import axios from "axios"
import http from "../utils/request"
//获取验证码
export let getCaptcha = ()=> http.get("/users/getCaptcha?v=next")

//校验验证码

export let verifyCaptcha = captcha => http.get("/users/verifyCaptcha",{
    params:{
        captcha
    }
})

//常规登入

export let loginApi = (username,password)=> http.post("/users/login",{
    username,
    password
})

//获取二维码地址

export let getQrCodeApi = (sid)=>  http.get("/users/getQrcode",{
    params:{
        sid
    }
})

//微信登入

export let wechatLoginApi = wechatCode => http.get('users/wechatLogin',{
    params:{
        wechatCode
    }
})

//获取手机验证码

export let getSmsCode = (phoneNumber) => http.post('/sms/send',{
        phoneNumber
})


//手机验证码登录

export let smsLogin = code => http.post("/users/login?type=sms",{
        code
})

//修改用户信息 /users/updateUser

//获取登入日志

/**
 * 
 * @param {*} componentInstance 
 * @param {String} page 第几页
 * @param {String} count 每页的数量
 * @returns {Promise} 返回一个promise
 */

export const getLoginLogApi = (componentInstance, page = 1, count = 15) =>
  http.get("/getloginlog", {
    params: {
      page,
      count,
    },
  });


  //获取所有的用户

  export const getAllUsersApi = () => http.get("/users/getAllUsers");